package com.ccom.core.common.exception;

import com.ccom.core.common.api.IResultCode;
import lombok.Data;

/**
 * @author zjj
 * @date 2021/10/29 15:53
 * @description
 */
@Data
public class RemindException extends RuntimeException {
    private static final String REMIND = "操作异常";

    private static final long serialVersionUID = 1L;

    /**
     * 提醒编码
     */
    private Integer code;

    /**
     * 提醒消息内容
     */
    private String defaultMessage;

    public RemindException(Integer code, String defaultMessage) {
        this.code = code;
        this.defaultMessage = defaultMessage;
    }

    public RemindException(Integer code) {
        this.code = code;
        this.defaultMessage = REMIND;
    }

    public RemindException(String defaultMessage) {
        this.code = 500;
        this.defaultMessage = defaultMessage;
    }

    public RemindException(IResultCode resultCode) {
        this.code = resultCode.getCode();
        this.defaultMessage = resultCode.getMessage();
    }
}
